#include <cstdio>


/*
    * 时间复杂度：O(mn)
    * 空间复杂度：O(1)
    * 
    * 数字图像处理
*/
int main() {
    int arr[110][110]{};
    int result[110][110]{};

    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &arr[i][j]);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int num = arr[i][j];
            num = num * 5;

            int topX = i - 1;
            int topY = j;

            int downX = i + 1;
            int downY = j;

            int leftX = i;
            int leftY = j - 1;

            int rightX = i;
            int rightY = j + 1;

            if (topX >= 0) {
                num -= arr[topX][topY];
            }
            if (downX < n) {
                num -= arr[downX][downY];
            }
            if (leftY >= 0) {
                num -= arr[leftX][leftY];
            }
            if (rightY < m) {
                num -= arr[rightX][rightY];
            }

            if (num < 0) {
                num = 0;
            }
            if (num > 255) {
                num = 255;
            }
            result[i][j] = num;

        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            printf("%d ", result[i][j]);
        }
        printf("\n");
    }


    return 0;

}